home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / Extension Shell 1.5 / Sample Extensions (1.5) / Quadra INIT ƒ / Gestalt.c < prev    next >
C/C++ Source or Header  |  1995-11-01  |  3KB  |  149 lines

  1. /*    NAME:
  2.         Gestalt.c
  3.  
  4.     WRITTEN BY:
  5.         Dair Grant
  6.                 
  7.     DESCRIPTION:
  8.         This file contains a code resource to be installed as a Gestalt
  9.         selector.
  10.  
  11.     NOTES:
  12.         We call the original gestaltMachineType selector, then munge the
  13.         return value to pretend we're always a Quadra 950.
  14.  
  15.     ___________________________________________________________________________
  16. */
  17. //=============================================================================
  18. //        Include files                                                                     
  19. //-----------------------------------------------------------------------------
  20. #include <Gestalt.h>
  21. #include "A4Stuff.h"
  22. #include "SetupA4.h"
  23. #include "ES Address Table.h"
  24. #include "QI Constants.h"
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. //=============================================================================
  41. //        Types                                                                 
  42. //-----------------------------------------------------------------------------
  43. typedef pascal OSErr (*GestaltSelectorProcPtr)(OSType gestaltSelector, long *gestaltResponse);
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. //=============================================================================
  60. //        Global Variables                                                                 
  61. //-----------------------------------------------------------------------------
  62. GestaltSelectorProcPtr        gPreviousSelector;
  63. Boolean                        gAlreadyRan = false;
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. //=============================================================================
  80. //        Private function prototypes                             
  81. //-----------------------------------------------------------------------------
  82. pascal OSErr main(OSType gestaltSelector, long *gestaltResponse);
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98. //=============================================================================
  99. //        main : Entry point to our code resource.                                                                 
  100. //-----------------------------------------------------------------------------
  101. //        Note :    We call the original Gestalt selector first then fudge the
  102. //                result to be a Quadra. We don't actually need to call the
  103. //                original routine, because it just so happens that the
  104. //                value returned isn't used to store other information apart
  105. //                from the machine type.
  106. //
  107. //                However, if the result was some kind of bit structure, we
  108. //                would need to use this method.
  109. //-----------------------------------------------------------------------------
  110. pascal OSErr main(OSType gestaltSelector, long *gestaltResponse)
  111. {    long                oldA4;
  112.     ESAddressTable        *theAddressTable;
  113.     OSErr                theErr;
  114.  
  115.     
  116.  
  117.     // Set up A4
  118. #ifndef powerc
  119.     oldA4 = SetCurrentA4();
  120. #endif
  121.     
  122.     
  123.     
  124.     // If we've not already been called, do our one time initialisation stuff
  125.     if (!gAlreadyRan)
  126.         {
  127.         Gestalt(kMacTypeAddressTable, (long *) &theAddressTable);        
  128.         gPreviousSelector    = (GestaltSelectorProcPtr) ((long) theAddressTable->theTable[kMacType]);
  129.         gAlreadyRan            = true;
  130.         }
  131.  
  132.  
  133.     // Call the original routine
  134.     theErr = gPreviousSelector(gestaltSelector, gestaltResponse);
  135.     
  136.     
  137.     // Fudge the response to what we want
  138.     *gestaltResponse = gestaltQuadra950;
  139.     theErr = noErr;
  140.  
  141.     
  142.  
  143.     // Restore A4 and return
  144. #ifndef powerc
  145.     SetA4(oldA4);
  146. #endif
  147.     return(theErr);
  148. }
  149.